package com.es.disped.common.wechat.http.config;

public class HttpConfig{
	
	//private final String resource="/properties/http.properties";
    /**
     * 最大连接数
     */
    private static int maxTotal=100;
    /**
     * 并发数
     */
    private static int defaultMaxPerRoute=20;
    /**
     * 创建连接的最长时间
     */
    private static int connectTimeout=1000;
    /**
     * 从连接池获取连接的最长时间
     */
    private static int connectionRequestTimeout=500;
    /**
     * 数据传输最长时间
     */
    private static int socketTimeout=10000;
    /**
     * 提交请求之前测试连接是否可用
     */
    private static boolean staleConnectionCheckEnabled=true;
    
//	public HttpConfig() {
//		this.maxTotal=Integer.valueOf(
//				this.propertiesValue(resource, "client.http.maxTotal"));
//		this.defaultMaxPerRoute=Integer.valueOf(
//				this.propertiesValue(resource, "client.http.defaultMaxPerRoute"));
//		this.connectTimeout=Integer.valueOf(
//				this.propertiesValue(resource, "client.http.connectTimeout"));
//		this.connectionRequestTimeout=Integer.valueOf(
//				this.propertiesValue(resource, "client.http.connectionRequestTimeout"));
//		this.socketTimeout=Integer.valueOf(
//				this.propertiesValue(resource, "client.http.socketTimeout"));
//		this.staleConnectionCheckEnabled=Boolean.valueOf(
//				this.propertiesValue(resource, "client.http.staleConnectionCheckEnabled"));
//	}

	public static int getMaxTotal() {
		return maxTotal;
	}

	public static void setMaxTotal(int maxTotal) {
		HttpConfig.maxTotal = maxTotal;
	}

	public static int getDefaultMaxPerRoute() {
		return defaultMaxPerRoute;
	}

	public static void setDefaultMaxPerRoute(int defaultMaxPerRoute) {
		HttpConfig.defaultMaxPerRoute = defaultMaxPerRoute;
	}

	public static int getConnectTimeout() {
		return connectTimeout;
	}

	public static void setConnectTimeout(int connectTimeout) {
		HttpConfig.connectTimeout = connectTimeout;
	}

	public static int getConnectionRequestTimeout() {
		return connectionRequestTimeout;
	}

	public static void setConnectionRequestTimeout(int connectionRequestTimeout) {
		HttpConfig.connectionRequestTimeout = connectionRequestTimeout;
	}

	public static int getSocketTimeout() {
		return socketTimeout;
	}

	public static void setSocketTimeout(int socketTimeout) {
		HttpConfig.socketTimeout = socketTimeout;
	}

	public static boolean isStaleConnectionCheckEnabled() {
		return staleConnectionCheckEnabled;
	}

	public static void setStaleConnectionCheckEnabled(boolean staleConnectionCheckEnabled) {
		HttpConfig.staleConnectionCheckEnabled = staleConnectionCheckEnabled;
	}

    @Override
    public String toString() {
        return "HttpConfig{" +
                "maxTotal=" + maxTotal +
                ", defaultMaxPerRoute=" + defaultMaxPerRoute +
                ", connectTimeout=" + connectTimeout +
                ", connectionRequestTimeout=" + connectionRequestTimeout +
                ", socketTimeout=" + socketTimeout +
                ", staleConnectionCheckEnabled=" + staleConnectionCheckEnabled +
                '}';
    }
}
